package com.wp._2016校招.去哪儿;

/**
 * Created by 王萍 on 2017/9/19 0019.
 */
public class 首个重复字符 {

    public static void main(String[] args) {
        String str = "qywyer23tdd";
        System.out.println(findFirstRepeat(str, str.length()));
    }

    public static char findFirstRepeat(String A, int n) {
        boolean[] array = new boolean[256];
        char[] chars = A.toCharArray();
        for (int i = 0; i < n; i++) {
            if (array[chars[i]] == false) {
                array[chars[i]] = true;
            } else return chars[i];
        }
        return '0';
    }
}
